import React, { useEffect, useState } from 'react';
import { useParams } from 'react-router-dom';
import { inject, observer } from 'mobx-react';
import Title from '../../components/title';
import MarkDownCom from '../../components/markdown';
import './index.less';

function MarkDown(props: any) {
  console.log('MarkDown proops', props);

  const routeParams: any = useParams();
  const routeTitle = routeParams.title;

  const [markdown, setMarkdown] = useState('');

  // 初始为开发文档
  useEffect(() => {
    fetch('/markdown/test.md').then(async (res) => {
      const response = await res.text();
      setMarkdown(response);
    });
  }, []);
  return (
    <div className='markdown'>
      <Title title={routeTitle} left={true} />
      <MarkDownCom data={markdown} />
    </div>
  );
}
export default inject('languageStore', 'rtlStore')(observer(MarkDown));
